package buf;/*

 */

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.util.CharsetUtil;

/**
 * @ClassName NettyBuf
 * @Author Final
 * @Project DataStructures
 */
public class NettyBuf {

    public static void main(String[] args) {
        ByteBuf buf = Unpooled.copiedBuffer("hello,哈喽", CharsetUtil.UTF_8);

        if (buf.hasArray()){

            byte[] array = buf.array();

            System.out.println(new String(array,CharsetUtil.UTF_8));
            /*for (int arg : array) {
                System.out.println(buf.readerIndex());
            }*/
            System.out.println(buf.readableBytes());
        }
    }
}
